package zb.stream;

import java.util.Arrays;
import java.util.List;
import java.util.Random;
import java.util.stream.DoubleStream;
import java.util.stream.IntStream;
import java.util.stream.Stream;

/**
 * @author wzby
 * @Date: 2022/8/6 9:53
 */
public class Stream3 {
    public static void main(String[] args) {
        List<String> list = List.of("a","b","c","d");
        Stream<String> s1 = list.stream().skip(1).limit(3);
        s1.forEach(System.out::println);

        int [] num = {1,2,3};
        IntStream is = Arrays.stream(num);
        Stream<Integer> is2 = Stream.of(1,2,3);
        DoubleStream ds = DoubleStream.generate(() -> java.lang.Math.random()).limit(5);
        ds.forEach(System.out::println);
        System.out.println();

        //1-100中随机输出十个数
        IntStream is3 = IntStream.generate(() -> {
            Random rand = new Random();
            return rand.nextInt(1,101);
        }).limit(10);
        is3.forEach(System.out::println);
    }
}
